<template>
  <div class="mod-config">
    <el-card class="box-card">
      <p style="font-size: 20px; text-align: center">推广10人以上订单交易奖励</p>
      <div style="margin-top: 100px; text-align: center">
        <el-radio v-model="dataForm.value" label="1" border size="medium">开启</el-radio>
        <el-radio v-model="dataForm.value" label="2" border size="medium">关闭</el-radio>
      </div>
      <div style="margin-top: 150px; margin-right: 30px; float: right">
      <span>
        <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
      </span>
      </div>
    </el-card>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        dataForm: {
          id: 0,
          value: ''
        },
        dataList: []
      }
    },
    // components: {
    //   AddOrUpdate
    // },
    activated () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.$http({
          url: this.$http.adornUrl('/setting/getOrderAward'),
          method: 'get',
          params: this.$http.adornParams()
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataForm.value = data.data.value
            this.dataForm.id = data.data.id
          } else {
            this.dataForm.value = ''
          }
        })
      },
      dataFormSubmit () {
        this.$http({
          url: this.$http.adornUrl(`/setting/modifyOrderAwardById`),
          method: 'post',
          data: this.$http.adornData({
            'id': this.dataForm.id || undefined,
            'value': this.dataForm.value
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message('修改成功')
          } else {
            this.$message.error(data.msg)
          }
        })
      }
    }
  }
</script>
<style>
  .box-card {
    width: 480px;
    height: 480px;
  }
</style>

